package com.shujia.mr.tuijian;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class RecommendDemo {
    public static void main(String[] args) throws Exception{
        Configuration conf = new Configuration();

        Job job = Job.getInstance(conf);

        job.setJobName("分析好友关系MR程序");

        job.setJarByClass(RecommendDemo.class);

        job.setMapperClass(RecommendMap.class);
        job.setReducerClass(RecommendReduce.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(LongWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        FileInputFormat.addInputPath(job,new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));

        boolean flag = job.waitForCompletion(true);
        //flag标志意思是执行的成功与否
        if (flag) {
            System.out.println("==================29期分析好友关系MR程序执行成功！！==================");
        } else {
            System.out.println("=========程序执行失败！！=====================");
        }

    }
}
